package com.tz.crm.utils;

import com.tz.crm.controller.IConst;
import com.tz.crm.entity.User;

import javax.servlet.http.HttpSession;

/**
 * HttpSession Util
 */
public class HttpSessionUtil {

    /**
     * 从 HttpSession 获取登录用户
     *
     * @param httpSession HttpSession
     * @return User
     */
    public static User getLoginUser(HttpSession httpSession) {
        User loginUser = (User) httpSession.getAttribute(IConst.LOGIN_USER);
        return loginUser;
    }

    /**
     * setLoginUser
     *
     * @param httpSession HttpSession
     * @param user        User
     */
    public static void setLoginUser(HttpSession httpSession, User user) {
        httpSession.setAttribute(IConst.LOGIN_USER, user);
    }
}
